<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>获取地理位置坐标</title>
  <script>
    window.onload = function () {
      window.navigator.geolocation.getCurrentPosition((position) => {
        console.log(position);
        console.log('东经', position.coords.longitude);
        console.log('北纬', position.coords.latitude);
      })

    }
  </script>
</head>

<body>

</body>

</html>